package com.scud.order.client;

import com.scud.client.order.IOrderClient;
import com.scud.model.order.dto.FullOrderDto;
import com.scud.order.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
public class OrderClient implements IOrderClient {

    @Autowired
    private OrderService orderService;

    /**
     * feign远程调用,在数据库中创建订单
     * @param orderDto
     */
    @Override
    @PostMapping("/api/order/feign/createOrder")
    public void createOrder(@RequestBody FullOrderDto orderDto) {
        log.info("feign远程调用,在数据库中创建订单:{}", orderDto);
        orderService.saveAOrder(orderDto);
    }
}
